<template>
	<view v-if="goToOld">
		<ot-signature-old  @sumbit="sumbit"  @fail="fail" cid="ceshi1"/>
	</view>
	<view v-else>
		<ot-signature @sumbit="sumbit" :name="userName"  @fail="fail" :bottomTips="bottomTips" cid="ceshi1"></ot-signature>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				storageKey: "signature-key",
				bottomTips:'',
				userName:'',
				goToOld:true
			}
		},
		mounted() {
			this.$nextTick(function() {
			});

		},
		methods: {	
			sumbit(res){
				try {
					var pages = getCurrentPages();
					var prePage = pages[pages.length - 2];
					prePage.$vm.isSign = true
					//#ifdef H5
				    uni.setStorageSync(this.storageKey, res.tempFilePath);
					//#endif
					//#ifdef APP-PLUS
					uni.setStorageSync(this.storageKey, res);
					//#endif
					uni.navigateBack();
				} catch (e) {
				    // error
				}
			},
			fail(err){
				console.log('fail',err)
			},
		},
		onLoad(options) {
			if(options.goToOld){
				this.goToOld = true
			}
			if(options.storageKey){
				this.storageKey = options.storageKey
			}
			if(options.bottomTips){
				this.bottomTips = options.bottomTips
			}
			if(options.userName){
				this.userName = options.userName
			}
		}
	}
</script>

<style>

</style>
